package com.eBook.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.eBook.dao.BookShelfDao;
import com.eBook.entity.Book;
import com.eBook.service.BookShelfService;

@Service
public class BookShelfServiceImpl implements BookShelfService {

	@Autowired
	BookShelfDao bookShelfDao;

	/**
	 * 新增一本书
	 * @param userAccount
	 * @param bookId
	 * @return
	 */
	@Override
	public int addBookToShelf(String userId, String bookId) {
		// TODO Auto-generated method stub
		return bookShelfDao.addBookToShelf(userId, bookId);
	}

	/**
	 * 通过uid找到书架上所有的书籍
	 * @param userId
	 * @return
	 */
	@Override
	public List<Book> findBookByUId(String userId) {
		// TODO Auto-generated method stub
		List<Book> books = bookShelfDao.findBookByUId(userId);
		System.out.println(books.size());
		return books;
	}

	/**
	 * 删除一本或多本
	 * @param map
	 * @return
	 */
	@Override
	public int deleteBookFromShelf(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return bookShelfDao.deleteBookFromShelf(map);
	}
}
